<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>字符串2</title>

</head>
<body>
	<script type="text/javascript">
		// 字符串截取 slice substr substring
		// slice: 从哪截到哪
		// substr:从哪开始截取几个
		// substring:负数无效为0 同slice
		// let hd = "zifuchuan"
		// console.log(hd.slice(1,3))
		// console.log(hd.substr(1,3))
		// console.log(hd.substring(1))


		//字符串检索
		// let hd = "zifuchuaN"
		// //查找 .indexOf includes
		// console.log(hd.lastIndexOf("c",)) //没有就反回-1 所以找时判断 ==-1
		// console.log(hd.includes("z"))
		// console.log(hd.startsWith("z"))
		// //不区分大小写
		// console.log(hd.toLowerCase().endsWith("n"))

		//字符串替代
		// const word = ["js","css"]
		// const str = "我会成为js和css人柱力"
		// const string =word.reduce((pre,word)=>{
		// 	// console.log(pre) ↓word
		// 	// console.log(word) 循环word
		// 	return pre.replace(word,`<a href="去往js">${word}</a>`)
		// },str)
		// document.write(string)
		
		//字符串重复
		// 电话模糊处理 654654***
		function blurPhone(num,len = 3){
			return String(num).slice(0,-len)+"*".repeat(len)
		}
		
		console.log(blurPhone(1231654121,5))
	</script>
</body>
</html>